#include "stdafx.h"
#include "TriangleFactory.h"

TriangleFactory *TriangleFactory::tf = 0;

TriangleFactory *TriangleFactory::getInstance(){
	if (tf == 0){
		tf = new TriangleFactory();
	}
	return tf;
}

void TriangleFactory::reset(){
	for (std::vector<Triangle *>::iterator iter = triangles.begin(); iter != triangles.end(); /* no increment */){
		delete (*iter);
		iter = triangles.erase(iter);
	}
}

Triangle* TriangleFactory::createTriangle(Point *p0, Point *p1, Point *p2, vector3 initNorm){
	Triangle *result = new Triangle(p0, p1, p2, initNorm);
	triangles.push_back(result);
	return result;
}